The Semantic Web is a construction game!
=> need for adapted frameworks
=> web apps AND semantic apps in one framework
=> web apps AND semantic apps in one framework
=> agile and iterative development
=> efficient development and maintenance
class Blog(EntityType):
title = String(maxsize=50, required=True)
description = String()
class BlogEntry(EntityType):
title = String(required=True, fulltextindexed=True)
content = String(required=True, fulltextindexed=True)
class entry_of(RelationDefinition):
subject = 'BlogEntry'
object = 'Blog'
__use__ = ('blog', 'comment', 'tag',)
class comments(RelationDefinition):
subject = 'Comment'
object = 'BlogEntry'
class tags(RelationDefinition):
subject = 'Tag'
object = 'BlogEntry'
Any X ORDERBY CD DESC LIMIT 10
WHERE X is BlogEntry, X creation_date CD
also UNION, EXISTS, sub-queries, optional variables (outer join), etc.
Any X WHERE T tags X,
T name IN ('cubicweb', 'semantic'), X is BlogEntry
SELECT * FROM BlogEntryTable, TagTable, TagsRelationTable
WHERE BlogEntryTable.eid = TagsRelationTable.beid AND
TagTable.name IN ('cubicweb','semantic') AND
TagTable.eid = TagsRelationTable.teid
A view is defined by:
When one want to use a view, it asks the registry to select the most suitable view of the given identifier according to a context.
For a better design and easier code reuse, views can use adapters to prevent incompatible interfaces.
class iCalView(EntityView):
__select__ = adaptable('ICalendarable')
# generate the iCal file to output
class BlogEntryICalendarableAdapter(EntityAdapter):
__regid__ = 'ICalendarable'
__select__ = is_instance('BlogEntry')
@property
def start(self):
return self.entity.creation_date
@property
def stop(self):
return self.entity.creation_date
=> publish data in RDF: LinkedData !
class Root(controllers.RootController):
cwdb = CubicWebDatabase('bookdb', 'admin', 'admin')
@expose(template="cubictg.templates.welcome")
def index(self, rql=''):
rset, colnames = [], []
if rql:
rset = self.cwdb.execute(rql)
colnames = get_col_names(rset)
return dict(rql=rql, rset=rset, colnames=colnames)